#delimit;
capture log close;
set more off;
pause on;
clear all;
set scheme plottig;

cap cd "/Users/deandulay/Dropbox/Myanmar_JOP_EGI_replication";
cap cd "C:\Users\ejm5\Dropbox\Myanmar_JOP_EGI_replication";

/*Use MBEI Official Cross-Sectional Data from 2020*/
#delimit;
use "data\20200419_mbei2020_cross", clear;

/*******************************************************ENTRY COSTS******************************************************/


lab var  state_region "State/Region";
lab var township "Township";

/*Subindex 1*/
lab var cdcordao_numberprocess "8. Number of procedures needed to apply for CDC or DAO operating license";
lab var numberprocess_DICA "9. Number of procedures needed to apply for DICA registration certificate (#)" ;
lab var numberprocess_DISI "10. Number of procedures needed to apply for DISI registration certificate (#)";
lab var dao_capacity "12.  Agreement that DAO office is working at capacity (%)";
lab var dao_physicalresources "13. Agreement that DAO office has necessary physical resources (%)";
lab var oss_capacity "14. OSS office operating at capacity (%)";
lab var oss_physicalresources "15. OSS office has physical resources";
lab var oss_helpfulstaff "16. OSS office staff are friendly and helpful (%)";
lab var dao_applicationavailable "17. DAO standard application form exists and is available (%)";


/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex1_surveyNEW=rowmean(rescale_cdcordao_numberprocess rescale_numberprocess_DICA rescale_numberprocess_DISI); 
replace subindex1_surveyNEW=subindex1_survey*0.6;
lab var subindex1_surveyNEW "Entry Costs Sub-Index: New Survey Indicators";

#delimit
egen subindex1_hardNEW=rowmean(rescale_dao_capacity rescale_dao_physicalresources rescale_oss_capacity rescale_oss_helpfulstaff rescale_oss_physicalresources rescale_dao_applicationavailable);
replace subindex1_hardNEW=subindex1_hard*0.4;
lab var subindex1_hardNEW "Entry Costs Sub-Index: New Hard Indicators";

gen subindex1_finalNEW=subindex1_surveyNEW + subindex1_hardNEW;
lab var subindex1_finalNEW "Entry Costs Sub-Index: New Indicators";
/**************************************************************************************************************/
/*Subindex 2*/
#delimit;
lab var q45 "7. Firm had a land dispute over the past 2 years (%)";
lab var landcertificate "8. Firm has a Land Grant or Form 7 (%)";
lab var q33_2a "9. Firm owner owns land in another person's name (%).  Less secure when not in owner's name.";
lab var q41 "10. Firm faced obstacles acquiring or expanding business premises (%)";
lab var GAD_summ_required_docs "11. Number of documents required to obtain the GAD Land Grant (#)";
lab var DALMS_helpfulstaff "12. Agreement that DALMS staff is helpful (%)";
lab var gad_applicationavailable "13. GAD standard application form exists and is available (%)";
lab var dalms_appavailable "14. DALMS standard application form exists and is available (%)";
lab var gad_physicalresources "15. Agreement that GAD office has necessary physical resources (%)";
lab var dalms_physicalresources "16. Agreement that DALMS office has necessary physical resources (%)";
lab var gad_capacity "17. Agreement that GAD office is working at capacity (%)";
lab var DALMS_highcapacity "18. Agreement that DALMS office is working at capacity (%)";
lab var DALMS_summ_required_docs "19. Total number of documents required for DALMS land map (#)";


/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex2_surveyNEW=rowmean(rescale_q45 rescale_landcertificate rescale_q33_2a rescale_q41); 
replace subindex2_surveyNEW=subindex2_survey*0.6;
lab var subindex2_surveyNEW "Land Access & Security Sub-Index: New Survey Indicators";

#delimit
egen subindex2_hardNEW=rowmean(rescale_GAD_summ_required_docs rescale_DALMS_helpfulstaff rescale_gad_applicationavailable rescale_gad_applicationavailable
rescale_dalms_appavailable rescale_gad_physicalresources rescale_dalms_physicalresources rescale_gad_capacity rescale_DALMS_highcapacity rescale_DALMS_summ_required_docs);
replace subindex2_hardNEW=subindex2_hard*0.4;
lab var subindex1_hardNEW "Land Access & Security Sub-Index: New Hard Indicators";

gen subindex2_finalNEW=subindex2_surveyNEW + subindex2_hardNEW;
lab var subindex2_finalNEW "Land Access & Security Sub-Index: New Indicators";

/**************************************************************************************************************/
/*Subindex 3*/
lab var  t_q71_6_binary "12. Fee rates are made easily available by government disclosures (%)";
lab var  q80 "13. Time taken to examine and inspect the business (minutes)";
lab var  q81_binary "14. Government agencies are technically competent (%)";
lab var  q74 "15. Number of inspections disrupts business operations (%)";
lab var DAO_summ_renewal_docs "16. Number of documents required to renew DAO business operating license (#)";
lab var GAD_summ_renewal_docs "17. Number of documents required to renew GAD Land Grant (#)";
lab var dao_helpfulstaff "18.  DAO staff helpful (%)";



/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex3_surveyNEW=rowmean(rescale_t_q71_6_binary rescale_q80 rescale_q81_binary rescale_q74); 
replace subindex3_surveyNEW=subindex3_survey*0.6;
lab var subindex3_surveyNEW "Post-Entry Regulation Sub-Index: New Survey Indicators";

#delimit
egen subindex3_hardNEW=rowmean(rescale_DAO_summ_renewal_docs rescale_dao_helpfulstaff);
replace subindex3_hardNEW=subindex3_hard*0.4;
lab var subindex1_hardNEW "Post-Entry Regulation Sub-Index: New Hard Indicators";

gen subindex3_finalNEW=subindex3_surveyNEW + subindex3_hardNEW;
lab var subindex3_finalNEW "Post-Entry Regulation Sub-Index: New Indicators";

/**************************************************************************************************************/

/*Subindex 4*/
lab var  q110_8 "9. Needs to pay a gift or money to get loan (%)";

/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex4_surveyNEW=rowmean(rescale_q110_8); 
lab var subindex4_surveyNEW "Informal Payments Sub-Index: New Survey Indicators";


gen subindex4_finalNEW=subindex4_surveyNEW;
lab var subindex4_finalNEW "Informal Payments Sub-Index: New Indicators";

/**************************************************************************************************************/

/*Subindex 5*/
lab var q52  "14. Number of last 5 outages that were informed in advance (#)";
lab var t_q46_2_binary  "15. Rural roads are good or very good (%)";
lab var duration_privatehome  "16. Duration between registration and receiving electricity access (private home meter, days)";
lab var duration_publichome  "17. Duration between registration and receiving electricity access (public home meter, days)";
lab var duration_privatepower   "18. Duration between registration and receiving electricity access (private power meter, days)";
lab var duration_publicpower  "19. Duration between registration and receiving electricity access (public power meter, days)";
lab var pct_accessinternet "21. Individuals aged 15 and above that used the internet in the last 7 days (%)";
lab var railroad_density "22. Railroad density (km rail/land area)";
lab var roaddensity_weighted "23. Road density weighted by road type (km road/land area*type)";
lab var public_community_grid "24. Population with public community grid (%)";



/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex5_surveyNEW=rowmean(rescale_q52 rescale_t_q46_2_binary rescale_duration_privatehome rescale_duration_publichome rescale_duration_privatepower rescale_duration_publicpower); 
replace subindex5_surveyNEW=subindex5_survey*0.6;
lab var subindex5_surveyNEW "Infrastructure Sub-Index: New Survey Indicators";

#delimit
egen subindex5_hardNEW=rowmean(rescale_pct_accessinternet rescale_railroad_density rescale_roaddensity_weighted rescale_public_community_grid);
replace subindex5_hardNEW=subindex5_hard*0.4;
lab var subindex1_hardNEW "Infrastructure Sub-Index: New Hard Indicators";

gen subindex5_finalNEW=subindex5_surveyNEW + subindex5_hardNEW;
lab var subindex5_finalNEW "Infrastructure Sub-Index: New Indicators";

/**************************************************************************************************************/
/*Subindex 6*/
lab var DAO_exam_provided "15. Share of DAO documents with examples provided";
lab var DALMS_exam_provided "16. Share of DALMS documents with examples provided";
lab var DALMS_pct_info_posted "17. Share of DALMS documents with information publicly posted";
lab var dao_schedule_fee "18. Ease of available information for DAO schedule of fees (score of 1-3)";
lab var transparency_survey "19. Score (for government websites) on transparency survey (over 15)";

/*******************************Firm Level Subindex New Indicators**************************************/
#delimit
egen subindex6_hardNEW=rowmean(rescale_DAO_exam_provided rescale_DALMS_exam_provided rescale_DALMS_pct_info_posted rescale_dao_schedule_fee rescale_transparency_survey );
lab var subindex1_hardNEW "Transparency Sub-Index: New Hard Indicators";

gen subindex6_finalNEW=subindex6_hardNEW;
lab var subindex6_finalNEW "Transparency Sub-Index: New Indicators";


/**************************************************************************************************************/
/*Subindex 7*/
lab var t_q143_7 "8. Other privileges and favoritism (%)";

#delimit;
egen subindex7_surveyNEW=rowmean(rescale_t_q143_7); 
lab var subindex7_surveyNEW "Favoritism Sub-Index: New Survey Indicators";


gen subindex7_finalNEW=subindex7_surveyNEW;
lab var subindex7_finalNEW "Favoritism Sub-Index: New Indicators";

/**************************************************************************************************************/

/*Subindex 8*/
lab var t_q120_3  "8. State support for air pollution reduction (%)";
lab var t_q120_4  "9. State support for water pollution reduction (%)";
lab var t_q120_5 "10. State support for electricity saving (%)";
lab var number_trucks "11. Number of garbage trucks per 10,000 people (#)";
lab var carbonintensity "12. Road transport carbon intensity of the economy";


/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex8_surveyNEW=rowmean(rescale_t_q120_3 rescale_t_q120_4 rescale_t_q120_5); 
replace subindex8_surveyNEW=subindex8_survey*0.6;
lab var subindex8_surveyNEW "Environmental Compliance Sub-Index: New Survey Indicators";

#delimit
egen subindex8_hardNEW=rowmean(rescale_number_trucks rescale_carbonintensity);
replace subindex8_hardNEW=subindex8_hard*0.4;
lab var subindex1_hardNEW "Environmental Compliance Sub-Index: New Hard Indicators";

gen subindex8_finalNEW=subindex8_surveyNEW + subindex8_hardNEW;
lab var subindex8_finalNEW "Environmental Compliance Sub-Index: New Indicators";

/**************************************************************************************************************/

/*Subindex 9*/
lab var q61 "8. Firm needs to train new employees (%)";
lab var q65_binary  "9. Quality of local labor meets the firm's needs (%)";
lab var q62  "10. Number of days after hiring that employee can do the job (#)";
lab var Highschool_Enrolment "11. High school enrollment rates (%)";
lab var placements_per10k "12. Labor exchange office placements per 10k (#)";

/*******************************Firm Level Subindex New Indicators**************************************/
#delimit;
egen subindex9_surveyNEW=rowmean(rescale_q61 rescale_q65_binary rescale_q62); 
replace subindex9_surveyNEW=subindex9_survey*0.6;
lab var subindex9_surveyNEW "Labor Recruitment Sub-Index: New Survey Indicators";

#delimit
egen subindex9_hardNEW=rowmean(rescale_Highschool_Enrolment rescale_placements_per10k);
replace subindex9_hardNEW=subindex9_hard*0.4;
lab var subindex1_hardNEW "Labor Recruitment Sub-Index: New Hard Indicators";

gen subindex9_finalNEW=subindex9_surveyNEW + subindex9_hardNEW;
lab var subindex9_finalNEW "Labor Recruitment Sub-Index New Indicators";

/**************************************************************************************************************/

/*Subindex 10*/
lab var judges "13. Number of judges per 10,000 citizens";
lab var riots_protests "14. Number of riots and protests per 10,000 citizens";
lab var armedclashes "15. Number of armed clashes per 10,000 citizens";


/*******************************Firm Level Subindex New Indicators**************************************/
#delimit
egen subindex10_hardNEW=rowmean(rescale_judges rescale_riots_protests rescale_armedclashes);
lab var subindex1_hardNEW "Law & Order Sub-Index: New Hard Indicators";

gen subindex10_finalNEW=subindex10_hardNEW;
lab var subindex10_finalNEW "Law & Order Sub-Index: New Indicators";


/**************************************************************************************************************/


#delimit;
egen unweighted_NEW=rowtotal(subindex1_final subindex2_final subindex3_final subindex4_final subindex5_final subindex6_final subindex7_final subindex8_final subindex9_final subindex10_final);
lab var unweighted_NEW "Unweighted MBEI: New Indicators";

egen unweighted_SURVEY_NEW=rowtotal(subindex1_surveyNEW subindex2_surveyNEW subindex3_surveyNEW subindex4_surveyNEW subindex5_surveyNEW subindex7_surveyNEW subindex8_surveyNEW subindex9_surveyNEW);
lab var unweighted_SURVEY_NEW "Unweighted MBEI: Survey,New Indicators";

egen unweighted_HARD_NEW=rowtotal(subindex1_hardNEW subindex2_hardNEW subindex3_hardNEW subindex5_hardNEW subindex6_hardNEW subindex8_hardNEW subindex9_hardNEW subindex10_hardNEW);
lab var unweighted_HARD_NEW "Unweighted MBEI: Hard,New Indicators";


/*******************************DAO Subindex New Indicators**************************************/
#delimit;
egen DAO_surveyNEW=rowmean(rescale_cdcordao_numberprocess rescale_DAO_summ_renewal_docs rescale_t_q71_6_binary rescale_t_q46_2_binary); 
replace DAO_surveyNEW=DAO_survey*0.6;
lab var DAO_surveyNEW "DAO Index: New Survey Indicators";

#delimit
egen DAO_hardNEW=rowmean(rescale_dao_capacity rescale_dao_physicalresources rescale_dao_applicationavailable rescale_DAO_summ_renewal_docs rescale_dao_helpfulstaff  rescale_DAO_exam_provided rescale_dao_schedule_fee);
replace DAO_hardNEW=DAO_hard*0.4;
lab var DAO_hardNEW "DAO Index: New Hard Indicators";

gen DAO_finalNEW=DAO_surveyNEW + DAO_hardNEW;
lab var DAO_finalNEW "DAO Index: New Indicators";
/**************************************************************************************************************/

/*******************************GAD New Indicators**************************************/
#delimit;
egen GAD_surveyNEW=rowmean(rescale_landcertificate rescale_q41); 
replace GAD_surveyNEW=GAD_survey*0.6;
lab var GAD_surveyNEW "GAD Index: New Survey Indicators";

#delimit
egen GAD_hardNEW=rowmean(rescale_GAD_summ_required_docs rescale_gad_applicationavailable rescale_gad_applicationavailable rescale_gad_physicalresources  rescale_gad_capacity  rescale_GAD_summ_renewal_docs rescale_riots_protests rescale_armedclashes);
replace GAD_hardNEW=GAD_hard*0.4;
lab var GAD_hardNEW "GAD Index: New Hard Indicators";

gen GAD_finalNEW=GAD_surveyNEW + GAD_hardNEW;
lab var GAD_finalNEW "GAD Index: New Indicators";
/**************************************************************************************************************/


keep if panel==2;
generate year=2020;
keep year Panel_ID SbjNum  state_region township Bcode subindex1_surveyNEW subindex1_hardNEW subindex1_finalNEW subindex2_surveyNEW subindex2_hardNEW subindex2_finalNEW subindex3_surveyNEW subindex3_hardNEW subindex3_finalNEW subindex4_surveyNEW subindex4_finalNEW subindex5_surveyNEW subindex5_hardNEW subindex6_hardNEW subindex6_finalNEW subindex7_surveyNEW subindex7_finalNEW subindex8_surveyNEW subindex8_hardNEW subindex8_finalNEW subindex9_surveyNEW subindex9_hardNEW subindex9_finalNEW subindex10_hardNEW subindex10_finalNEW unweighted_NEW unweighted_SURVEY_NEW unweighted_HARD_NEW DAO_surveyNEW DAO_hardNEW DAO_finalNEW GAD_surveyNEW GAD_hardNEW GAD_finalNEW ;

save "data\20220324_MBEI_NewIndicators.dta", replace;






